home *** CD-ROM | disk | FTP | other *** search
- Path: news.acadia.net!usenet
- From: steven2@salesbook.com (Steve Nutt)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ error in borland, is this a compiler bug?
- Date: Sun, 03 Mar 1996 06:51:45 GMT
- Organization: DET
- Message-ID: <4hb6rg$9gm@post.acadia.net>
- References: <4h7suv$760@news2.realtime.net>
- Reply-To: steven2@salesbook.com
- NNTP-Posting-Host: blf7.acadia.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- brian_d@sheshunoff.com wrote:
-
- >I am using borland C++4.52, and OWL. Owl has very little to do with this, though.
- >GetModule() returns a TModule *. TModule has a member function LoadString that returns
- >a string object. string class has a member function c_str() that return a char * to the actual string.
-
- > BOOL newInstl;
- > long pgmDirSpace;
-
-
- >I get the following error when trying to compile the following (modified for example)
- >"Destructor for string required in conditional expression in function ..."
-
-
- > pgmDirSpace=newInstl ? atol((GetModule()->LoadString(ROOM_NEW)).c_str())
- > : atol((GetModule()->LoadString(ROOM_OVER)).c_str());
-
-
- >But if I change it to this, it works fine.
- > if(newInstl) pgmDirSpace=atol((GetModule()->LoadString(ROOM_NEW)).c_str());
- > else pgmDirSpace=atol((GetModule()->LoadString(ROOM_OVER)).c_str());
-
- >This will also compile fine. Thrown in for example only.
- > switch(newInstl)
- > {
- > case TRUE;
- > pgmDirSpace=atol((GetModule()->LoadString(ROOM_NEW)).c_str());
- > break;
-
- > default:
- > atol((GetModule()->LoadString(ROOM_OVER)).c_str());
- > }
-
-
- >I dont see any difference that should matter in any of these examples.
- >I obviously have a workaround, but I am also very currious.
- >Thanks for any answers to this mystery :o) !
- > Brian
-
- Yes this is basically a compiler bug, but I'm not sure Borland will
- admit it. There is nothing stopping you from doing this in the
- standard.
-
- The problem is with the ? operator and classes rather than
- GetModule()->LoadString. Many moons ago someone wrote an article
- about this bug. I don't remember who or where, but it was listed as
- 'Bug of the Month' (Dr Dobbs perhaps?)
-
- Steve
-
-